home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / Java / Pdapilot / Dlp.java < prev    next >
Text File  |  1997-08-09  |  11KB  |  264 lines

  1.  
  2. package Pdapilot;
  3.  
  4. import java.io.*;
  5.  
  6. public class Dlp extends Socket {
  7.         Dlp(int sock) { super(sock); }
  8.         synchronized public int dlp_OpenDB(int card, int mode, String name) throws DlpException
  9.             { return calls.dlp_OpenDB(socket, card, mode, name); }
  10.         synchronized public int dlp_CreateDB(Char4 creator, Char4 type, int card, int flags, int version, String name) throws DlpException
  11.             { return calls.dlp_CreateDB(socket, creator, type, card, flags, version, name); }
  12.         synchronized public int dlp_CloseDB(int handle) throws DlpException
  13.             { return calls.dlp_CloseDB(socket, handle); }
  14.         synchronized public int dlp_AddSyncLogEntry(String entry) throws DlpException
  15.             { return calls.dlp_AddSyncLogEntry(socket, entry); }
  16.         synchronized public Record dlp_ReadRecordByIndex(int handle, int index, Database dbClass) throws DlpException
  17.             { return calls.dlp_ReadRecordByIndex(socket, handle, index, dbClass); }
  18.         synchronized public Record dlp_ReadRecordByID(int handle, RecordID id, Database dbClass) throws DlpException
  19.             { return calls.dlp_ReadRecordByID(socket, handle, id, dbClass); }
  20.         synchronized public int dlp_WriteRecord(int handle, Record record) throws DlpException
  21.             { return calls.dlp_WriteRecord(socket, handle, record); }
  22.         synchronized public int dlp_WriteResource(int handle, Resource resource) throws DlpException
  23.             { return calls.dlp_WriteResource(socket, handle, resource); }
  24.         synchronized public Resource dlp_ReadResourceByType(int handle, Char4 type, int id, Database dbClass) throws DlpException
  25.             { return calls.dlp_ReadResourceByType(socket, handle, type, id, dbClass); }
  26.         synchronized public Resource dlp_ReadResourceByIndex(int handle, int index, Database dbClass) throws DlpException
  27.             { return calls.dlp_ReadResourceByIndex(socket, handle, index, dbClass); }
  28.         synchronized public CardInfo dlp_ReadStorageInfo(int card) throws DlpException
  29.             { return calls.dlp_ReadStorageInfo(socket, card); }
  30.         synchronized public java.util.Date dlp_GetSysDateTime() throws DlpException
  31.             { return calls.dlp_GetSysDateTime(socket); }
  32.         synchronized public UserInfo dlp_ReadUserInfo() throws DlpException
  33.             { return calls.dlp_ReadUserInfo(socket); }
  34.         synchronized public int dlp_WriteUserInfo(UserInfo info) throws DlpException
  35.             { return calls.dlp_WriteUserInfo(socket, info); }
  36.         synchronized public SysInfo dlp_ReadSysInfo() throws DlpException
  37.             { return calls.dlp_ReadSysInfo(socket); }
  38.         synchronized public void dlp_OpenConduit() throws DlpException
  39.             { calls.dlp_OpenConduit(socket); }
  40.         synchronized public NetInfo dlp_ReadNetSyncInfo() throws DlpException
  41.             { return calls.dlp_ReadNetSyncInfo(socket); }
  42.         synchronized public int dlp_WriteNetSyncInfo(NetInfo info) throws DlpException
  43.             { return calls.dlp_WriteNetSyncInfo(socket, info); }
  44.         synchronized public DBInfo dlp_ReadDBList(int card, int flags, int start) throws DlpException
  45.             { return calls.dlp_ReadDBList(socket, card, flags, start); }
  46.         synchronized public int dlp_DeleteDB(int card, String name) throws DlpException
  47.             { return calls.dlp_DeleteDB(socket, card, name); }
  48.         synchronized public int dlp_EndOfSync(int status) throws DlpException
  49.             { return calls.dlp_EndOfSync(socket, status); }
  50.         synchronized public int dlp_MoveCategory(int handle, int from, int to) throws DlpException
  51.             { return calls.dlp_MoveCategory(socket, handle, from, to); }
  52.         synchronized public int dlp_ResetSyncFlags(int handle) throws DlpException
  53.             { return calls.dlp_ResetSyncFlags(socket, handle); }
  54.         synchronized public int dlp_CleanUpDatabase(int handle) throws DlpException
  55.             { return calls.dlp_CleanUpDatabase(socket, handle); }
  56.         synchronized public int dlp_DeleteRecord(int handle, boolean all, RecordID id) throws DlpException
  57.             { return calls.dlp_DeleteRecord(socket, handle, all, id); }
  58.         synchronized public int dlp_DeleteResource(int handle, boolean all, Char4 type, int id) throws DlpException
  59.             { return calls.dlp_DeleteResource(socket, handle, all, type, id); }
  60.         synchronized public AppBlock dlp_ReadAppBlock(int handle, Database dbClass) throws DlpException
  61.             { return calls.dlp_ReadAppBlock(socket, handle, dbClass); }
  62.         synchronized public SortBlock dlp_ReadSortBlock(int handle, Database dbClass) throws DlpException
  63.             { return calls.dlp_ReadSortBlock(socket, handle, dbClass); }
  64.         synchronized public int dlp_WriteAppBlock(int handle, AppBlock appblock) throws DlpException
  65.             { return calls.dlp_WriteAppBlock(socket, handle, appblock); }
  66.         synchronized public int dlp_WriteSortBlock(int handle, SortBlock sortblock) throws DlpException
  67.             { return calls.dlp_WriteSortBlock(socket, handle, sortblock); }
  68.         synchronized public Pref dlp_ReadAppPreference(Char4 creator, int id, boolean backup, Database dbClass) throws DlpException
  69.             { return calls.dlp_ReadAppPreference(socket, creator, id, backup, dbClass); }
  70.         synchronized public int dlp_WriteAppPreference(Pref pref) throws DlpException
  71.             { return calls.dlp_WriteAppPreference(socket, pref); }
  72.         synchronized public int dlp_ReadOpenDBInfo(int handle) throws DlpException
  73.             { return calls.dlp_ReadOpenDBInfo(socket, handle); }
  74.         synchronized public int dlp_ReadFeature(Char4 creator, int id) throws DlpException
  75.             { return calls.dlp_ReadFeature(socket, creator, id); }
  76.         synchronized public Record dlp_ReadNextModifiedRec(int handle, Database dbClass) throws DlpException
  77.             { return calls.dlp_ReadNextModifiedRec(socket, handle, dbClass); }
  78.         synchronized public Record dlp_ReadNextModifiedRecInCategory(int handle, int category, Database dbClass) throws DlpException
  79.             { return calls.dlp_ReadNextModifiedRecInCategory(socket, handle, category, dbClass); }
  80.         synchronized public Record dlp_ReadNextRecInCategory(int handle, int category, Database dbClass) throws DlpException
  81.             { return calls.dlp_ReadNextRecInCategory(socket, handle, category, dbClass); }
  82.         synchronized public RecordID[] dlp_ReadRecordIDList(int handle, boolean sort, int start, int max) throws DlpException
  83.             { return calls.dlp_ReadRecordIDList(socket, handle, sort, start, max); }
  84.         synchronized public int dlp_DeleteCategory(int handle, int category) throws DlpException
  85.             { return calls.dlp_DeleteCategory(socket, handle, category); }
  86.         synchronized public int dlp_ResetDBIndex(int handle) throws DlpException
  87.             { return calls.dlp_ResetDBIndex(socket, handle); }
  88.         synchronized public int dlp_ResetSystem() throws DlpException
  89.             { return calls.dlp_ResetSystem(socket); }
  90.         synchronized public byte[] dlp_CallApplication(Char4 creator, int type, int action, byte[] data, int[] retcode)      throws DlpException
  91.             { return calls.dlp_CallApplication(socket, creator, type, action, data, retcode); }
  92.                 
  93.         public void close() throws DlpException, IOException {
  94.             /* This method must be idempotent */
  95.             if (this.socket != 0) {
  96.                 dlp_EndOfSync(constants.dlpEndCodeNormal);
  97.                 super.close();
  98.             }
  99.         }
  100.  
  101.         public void close(int status) throws DlpException, IOException {
  102.             /* This method must be idempotent */
  103.             if (this.socket != 0) {
  104.                 dlp_EndOfSync(status);
  105.                 super.close();
  106.             }
  107.         }
  108.  
  109.         public void close(end status) throws DlpException, IOException {
  110.             /* This method must be idempotent */
  111.             if (this.socket != 0) {
  112.                 dlp_EndOfSync(status.getValue());
  113.                 super.close();
  114.             }
  115.         }
  116.  
  117.         public void reset() throws DlpException {
  118.             dlp_ResetSystem();
  119.         }
  120.  
  121.         public DB open(Pdapilot.Database dbClass)
  122.             throws DlpException
  123.         {
  124.             int handle = this.dlp_OpenDB(0, 0x40|0x80|0x20, dbClass.dbname());
  125.             return new DB(this, handle, dbClass.dbname(), 0x40|0x80|0x20, 0, dbClass);
  126.         }
  127.         
  128.         public DB open(String name) throws DlpException { return this.open(name,0x40|0x80|0x20); }
  129.         public DB open(String name, int mode) throws DlpException { return this.open(name,mode,0); }
  130.         public DB open(String name, int mode, int card) throws DlpException {
  131.             int handle = this.dlp_OpenDB(card, mode, name);
  132.             return new DB(this, handle, name, mode, card);
  133.         }
  134.  
  135.         public DB open(String name, String mode) throws DlpException { return this.open(name,mode,0); }
  136.         public DB open(String name, String mode, int card) throws DlpException {
  137.             int imode = 0;
  138.             if (mode.indexOf('r')>=0)
  139.                 imode |= constants.dlpOpenRead;
  140.             if (mode.indexOf('w')>=0)
  141.                 imode |= constants.dlpOpenWrite;
  142.             if (mode.indexOf('s')>=0)
  143.                 imode |= constants.dlpOpenSecret;
  144.             if (mode.indexOf('x')>=0)
  145.                 imode |= constants.dlpOpenExclusive;
  146.             int handle = this.dlp_OpenDB(card, imode, name);
  147.             return new DB(this, handle, name, imode, card);
  148.         }
  149.         
  150.         public DB create(String name, Char4 creator, Char4 type, int flags, int version) throws DlpException
  151.             { return create(name, creator, type, flags, version, 0); }
  152.         public DB create(String name, Char4 creator, Char4 type, int flags, int version, int card) 
  153.             throws DlpException
  154.         {
  155.             int handle = this.dlp_CreateDB(creator, type, card, flags, version, name);
  156.             return new DB(this, handle, name, 0x80|0x40|0x20, card);
  157.         }
  158.         
  159.         public CardInfo getCardInfo(int card)
  160.             throws DlpException
  161.         {
  162.             return this.dlp_ReadStorageInfo(card);
  163.         }
  164.         
  165.         public java.util.Date getTime()
  166.             throws DlpException
  167.         {
  168.             return dlp_GetSysDateTime();
  169.         }
  170.  
  171.         public UserInfo getUserInfo()
  172.             throws DlpException
  173.         {
  174.             return dlp_ReadUserInfo();
  175.         }
  176.  
  177.         public SysInfo getSysInfo()
  178.             throws DlpException
  179.         {
  180.             return dlp_ReadSysInfo();
  181.         }
  182.         
  183.         public void getStatus()
  184.             throws DlpException, CancelSyncException
  185.         {
  186.             dlp_OpenConduit();
  187.         }
  188.  
  189.         public DBInfo getDBInfo(int start, boolean RAM, boolean ROM, int card)
  190.             throws DlpException
  191.         {
  192.             return dlp_ReadDBList(card, (RAM ? constants.dlpDBListRAM : 0) |
  193.                                         (ROM ? constants.dlpDBListROM : 0),
  194.                                         start);
  195.         }
  196.         
  197.         public int getFeature(Char4 type, int id)
  198.             throws DlpException
  199.         {
  200.             return dlp_ReadFeature(type, id);
  201.         }
  202.         
  203.         public Pref getPref(Char4 creator, int id)
  204.             throws DlpException
  205.         {    return getPref(creator, id, true); }
  206.         public Pref getPref(Char4 creator, int id, boolean backup)
  207.             throws DlpException
  208.         {
  209.             Database dbClass = (Database)Database.prefClasses.get(creator);
  210.             if (dbClass == null)
  211.                 dbClass = Database.defaultPrefClass;
  212.             return dlp_ReadAppPreference(creator, id, backup, dbClass);
  213.         }
  214.  
  215.         public Pref newPref(Char4 creator, int id)
  216.             throws DlpException
  217.         {    return newPref(creator, id, 1); }
  218.         public Pref newPref(Char4 creator, int id, int version)
  219.             throws DlpException
  220.         {    return newPref(creator, id, version, true); }
  221.         public Pref newPref(Char4 creator, int id, int version, boolean backup)
  222.             throws DlpException
  223.         {
  224.             Database dbClass = (Database)Database.prefClasses.get(creator);
  225.             if (dbClass == null)
  226.                 dbClass = Database.defaultPrefClass;
  227.             return dbClass.newPref(null, creator, id, version, backup);
  228.         }
  229.  
  230.         public void setPref(Pref pref)
  231.             throws DlpException
  232.         {
  233.             dlp_WriteAppPreference(pref);
  234.         }
  235.  
  236.         public NetInfo getNetInfo()
  237.             throws DlpException
  238.         {
  239.             return dlp_ReadNetSyncInfo();
  240.         }
  241.  
  242.         public void setNetInfo(NetInfo info)
  243.             throws DlpException
  244.         {
  245.             dlp_WriteNetSyncInfo(info);
  246.         }
  247.         
  248.         public void log(String message) throws DlpException {
  249.             dlp_AddSyncLogEntry(message);
  250.         }
  251.         
  252.         public byte[] callApplication(Char4 creator, int type, int action, byte[] data, int[] retcode)
  253.             throws DlpException
  254.         {
  255.             return dlp_CallApplication(creator, type, action, data, retcode);
  256.         }
  257.         
  258.         public void delete(String dbname) throws DlpException
  259.             {    delete(dbname, 0); }
  260.         public void delete(String dbname, int card) throws DlpException {
  261.             dlp_DeleteDB(card, dbname);
  262.         }
  263. }
  264.